{extend name="common/base_page" /}

{block name="title"}{$page_title}人员信息{/block}

{block name="jscssfile"}{/block}

{block name="css"}
<style type="text/css">
.layui-form-item .layui-input-inline {
    width: 350px;
}
.layui-btn-sm {
    height: 35px;
    line-height: 35px;
    margin-top: -5px;
}
</style>
{/block}

{block name="body"}
  <div class="layui-fluid" style="height: 100vh;overflow-y: scroll;">
    <div class="layui-card">
      <div class="layui-card-header">{$page_title}人员信息</div>
      <div class="layui-card-body public-tpl-row1" style="padding: 15px;">
        <form class="layui-form" action="" lay-filter="component-form-group">

        <div class="layui-col-md12">
            <div class="layui-col-md9">
                <fieldset class="layui-elem-field layui-field-title"><legend>基本信息</legend></fieldset>
                <div class="layui-form-item">
                  <div class="layui-inline">
                    <label class="layui-form-label">真实姓名</label>
                    <div class="layui-input-inline">
                      <input type="text" name="nickname" lay-verify="nickname" placeholder="人员真实姓名" autocomplete="off" maxlength="5" class="layui-input" value="{$info.nickname}"/>
                    </div>
                  </div>
                  <div class="layui-inline">
                    <label class="layui-form-label">人员工号</label>
                    <div class="layui-input-inline">
                      <input type="text" name="gonghao_code" lay-verify="gonghao_code" placeholder="填写人员工号" autocomplete="off" maxlength="10" class="layui-input" value="{$info.gonghao_code}"/>
                    </div>
                  </div>
                </div>
                <div class="layui-form-item">
                  <div class="layui-inline">
                    <label class="layui-form-label">登录账号</label>
                    <div class="layui-input-inline">
                      <input type="text" id="user_name" name="user_name" lay-verify="username" autocomplete="off" class="layui-input" value="{$info.user_name}" maxlength="15" placeholder="8到15位系统登录账号"/>
                    </div>
                  </div>
                  <div class="layui-inline">
                    <label class="layui-form-label">登录密码</label>
                    <div class="layui-input-inline">
                      <input type="password" name="user_pwd" lay-verify="pass"autocomplete="off" class="layui-input" placeholder="若不修改请留空" maxlength="32">
                    </div>
                  </div>
                </div>
                <div class="layui-form-item">
                  <div class="layui-inline">
                    <label class="layui-form-label">账号角色</label>
                    <div class="layui-input-inline">
                      <select name="group_id">
                          <option value="0" {if $info.group_id eq '0'}selected="true"{/if}>暂不分配角色</option>
                          {volist name="group_list" id="vo"}
                          <option value="{$vo.id}" {if $info.group_id eq $vo.id}selected="true"{/if}>{$vo.name}</option>
                          {/volist}
                      </select>
                    </div>
                  </div>
                  <div class="layui-inline">
                    <label class="layui-form-label">手机号码</label>
                    <div class="layui-input-inline">
                      <input type="text" name="user_mobile" lay-verify="user_mobile" autocomplete="off" class="layui-input" value="{$info.user_mobile}" maxlength="11" placeholder="若不修改请留空" readonly="true">
                    </div>
                  </div>
                </div>
                <div class="layui-form-item">
                  <div class="layui-inline">
                    <label class="layui-form-label">账号状态</label>
                    <div class="layui-input-inline">
                      <input type="checkbox" {if !$info || $info.status gt 0}checked="true"{/if} name="status" lay-skin="switch" lay-text="启用|停用">
                    </div>
                  </div>
                  <div class="layui-inline">
                    <label class="layui-form-label">性别</label>
                    <div class="layui-input-inline">
                      <input type="radio" name="sex" value="1" title="男" {if !$info || $info.sex eq '1'}checked="true"{/if}>
                      <input type="radio" name="sex" value="2" title="女" {if $info.sex eq '2'}checked="true"{/if}>
                      <input type="radio" name="sex" value="0" title="未知" {if $info.sex eq '0'}checked="true"{/if}>
                    </div>
                  </div>
                </div>

                <div class="layui-form-item">
                  <div class="layui-inline">
                    <label class="layui-form-label">所属科室</label>
                    <div class="layui-input-inline">
                      <select name="keshi_code">
                          {volist name="keshi_list" id="vo"}
                          <option value="{$vo.id}" {if $info.keshi_code eq $vo.id}selected="true"{/if}>{$vo.name}</option>
                          {/volist}
                      </select>
                    </div>
                  </div>
                  <div class="layui-inline">
                    <label class="layui-form-label">人员职位</label>
                    <div class="layui-input-inline">
                      <select name="zhiwei_code">
                          {volist name="zhiwei_list" id="vo"}
                          <option value="{$vo.id}" {if $info.zhiwei_code eq $vo.id}selected="true"{/if}>{$vo.name}</option>
                          {/volist}
                      </select>
                    </div>
                  </div>
                </div>
                <div class="layui-form-item">
                  <div class="layui-inline">
                    <label class="layui-form-label">证件类型</label>
                    <div class="layui-input-inline">
                      <select name="cert_code">
                          {volist name="zhengjian_list" id="vo"}
                          <option value="{$vo.id}" {if $info.cert_code eq $vo.id}selected="true"{/if}>{$vo.name}</option>
                          {/volist}
                      </select>
                    </div>
                  </div>
                  <div class="layui-inline">
                    <label class="layui-form-label">证件号码</label>
                    <div class="layui-input-inline">
                      <input type="text" name="cert_no" autocomplete="off" class="layui-input" value="{$info.cert_no}" placeholder="人员证件号码" maxlength="32">
                    </div>
                  </div>
                </div>
                <div class="layui-form-item">
                  <div class="layui-inline">
                    <label class="layui-form-label">毕业院校</label>
                    <div class="layui-input-inline">
                      <input type="text" name="biye_xuexiao" autocomplete="off" class="layui-input" value="{$info.biye_xuexiao}" placeholder="输入毕业院校">
                    </div>
                  </div>
                  <div class="layui-inline">
                    <label class="layui-form-label">最高学历</label>
                    <div class="layui-input-inline">
                      <select name="xueli_code">
                          {volist name="xueli_list" id="vo"}
                          <option value="{$vo.id}" {if $info.xueli_code eq $vo.id}selected="true"{/if}>{$vo.name}</option>
                          {/volist}
                      </select>
                    </div>
                  </div>
                </div>
                <div class="layui-form-item">
                  <label class="layui-form-label">最高职称</label>
                  <div class="layui-input-inline">
                    <select name="zhicheng_code">
                          <option value="" {if $info.zhicheng_code eq ''}selected="true"{/if}>未获得职称</option>
                          {volist name="zhicheng_list" id="vo"}
                          <option value="{$vo.id}" {if $info.zhicheng_code eq $vo.id}selected="true"{/if}>{$vo.name}</option>
                          {/volist}
                      </select>
                  </div>
                  <div class="layui-form-mid layui-word-aux">若已取得职称，请选择对应的职称</div>
                </div>

                <fieldset class="layui-elem-field layui-field-title"><legend>医师资格证信息</legend></fieldset>
                <div class="layui-form-item">
                  <div class="layui-inline">
                    <label class="layui-form-label" style="width:120px;">医师资格证书编号</label>
                    <div class="layui-input-inline" style="width:310px;">
                      <input type="text" name="yishi_cert_no" autocomplete="off" class="layui-input" value="{$info.yishi_cert_no}" placeholder="输入医师资格证书编号" maxlength="32">
                    </div>
                  </div>
                  <div class="layui-inline">
                    <label class="layui-form-label" style="width:120px;">医师资格证书图片</label>
                    <div class="layui-input-inline" style="width:310px;">
                      <input type="text" name="yishi_cert_img" autocomplete="off" class="layui-input" value="{$info.yishi_cert_img}" placeholder="上传医师资格证图片">
                    </div>
                  </div>
                  <a class="layui-btn layui-btn-primary layui-btn-sm" href="javascript:viewImg('yishi');">查看</a>
                  <a class="layui-btn layui-btn-sm layui-btn-normal" href="javascript:;" onclick="_Index.attachment(0,'selectYiShiZhengBackFun');">上传</a>
                </div>
                <div class="layui-form-item">
                  <div class="layui-inline">
                    <label class="layui-form-label">发证日期</label>
                    <div class="layui-input-inline">
                      <input type="text" name="yishi_cert_senddate" id="yishi_cert_senddate" autocomplete="off" class="layui-input" value="{$info.yishi_cert_senddate}" placeholder="医师资格证书发证日期格式yyyy-MM-dd" maxlength="11">
                    </div>
                  </div>
                  <div class="layui-inline">
                    <label class="layui-form-label">证书状态</label>
                    <div class="layui-input-inline">
                      <input type="checkbox" {if !$info || $info.yishi_cert_status gt 0}checked="true"{/if} name="yishi_cert_status" lay-skin="switch" lay-text="已审核|未审核">
                    </div>
                  </div>
                </div>

                <fieldset class="layui-elem-field layui-field-title"><legend>抗菌药物合格证信息</legend></fieldset>
                <div class="layui-form-item">
                  <div class="layui-inline">
                    <label class="layui-form-label" style="width:120px;">抗菌药物证书编号</label>
                    <div class="layui-input-inline" style="width:310px;">
                      <input type="text" name="kangjun_cert_no" autocomplete="off" class="layui-input" value="{$info.kangjun_cert_no}" placeholder="输入抗菌药物证书编号" maxlength="32">
                    </div>
                  </div>
                  <div class="layui-inline">
                    <label class="layui-form-label" style="width:120px;">抗菌药物证书图片</label>
                    <div class="layui-input-inline" style="width:310px;">
                      <input type="text" name="kangjun_cert_img" autocomplete="off" class="layui-input" value="{$info.kangjun_cert_img}" placeholder="上传抗菌药物合格格证图片">
                    </div>
                  </div>
                  <a class="layui-btn layui-btn-primary layui-btn-sm" href="javascript:viewImg('kangjun');">查看</a>
                  <a class="layui-btn layui-btn-sm layui-btn-normal" href="javascript:;" onclick="_Index.attachment(0,'selectKangJunBackFun');">上传</a>
                </div>
                <div class="layui-form-item">
                  <div class="layui-inline">
                    <label class="layui-form-label">发证日期</label>
                    <div class="layui-input-inline">
                      <input type="text" name="kangjun_cert_senddate" id="kangjun_cert_senddate" autocomplete="off" class="layui-input" value="{$info.kangjun_cert_senddate}" placeholder="抗菌药物合格证书发证日期格式yyyy-MM-dd" maxlength="11">
                    </div>
                  </div>
                  <div class="layui-inline">
                    <label class="layui-form-label">证书状态</label>
                    <div class="layui-input-inline">
                      <input type="checkbox" {if !$info || $info.kangjun_cert_status gt 0}checked="true"{/if} name="kangjun_cert_status" lay-skin="switch" lay-text="已审核|未审核">
                    </div>
                  </div>
                </div>

                <fieldset class="layui-elem-field layui-field-title"><legend>其它信息</legend></fieldset>
                <div class="layui-form-item">
                  <label class="layui-form-label">电子邮箱</label>
                  <div class="layui-input-inline">
                    <input type="text" name="email" autocomplete="off" class="layui-input" value="{$info.email}" maxlength="32"/>
                  </div>
                  <div class="layui-form-mid layui-word-aux">请输入个人电子邮箱，如：21234@qq.com</div>
                </div>
                
                <br/><br/>
            </div>
            <div class="layui-col-md3">
              <input type="hidden" name="img" value="{$info.img}"/>
              <div class="admin-avatar-box">
                  <div class="avatar-img">
                  {if $info.img}
                  <img src="{$info.img}" id="adminAvatar">
                  {else}
                  <i class="layui-icon layui-icon-add-circle"></i>
                  {/if}
                  </div>
                  <p class="avatar-txt">请上传真实个人照片，大小350x370</p>
              </div>
            </div>
        </div>

          <div class="layui-form-item layui-layout-admin">
            <div class="layui-input-block">
              <div class="layui-footer" style="left: 0;">
                <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="adminInfoForm">保存</button>
                <button type="reset" class="layui-btn layui-btn-danger" id="resetBtn">重置</button>
                <a class="layui-btn layui-btn-primary" href="{:url('index/clinic.admin/index')}">返回</a>
              </div>
            </div>
          </div>
          <input type="hidden" name="id" value="{$info.id}"/>
          <input type="hidden" name="old_user_name" value="{$info.user_name}"/>
          <input type="hidden" name="old_mobile" value="{$info.user_mobile}"/>
        </form>
      </div>
    </div>
  </div>
{/block}

{block name="script"}
<script src="__INDEX__/js/clinic/admin.js?v={$site.version}"></script>
<script type="text/javascript">
$(function(){
  $('.avatar-img').bind('click',function(){
      _Index.attachment(0); //单选
  });
  setTimeout(function(){
     $(".layui-form :input[name='user_name']").focus();
     laydate.render({ elem: '#yishi_cert_senddate' });
     laydate.render({ elem: '#kangjun_cert_senddate' });
  },100);
});
layui.use(['form'], function(){
    form = layui.form;
    form.render(null, 'component-form-group');
    /* 自定义验证规则 */
    form.verify({
      username: [/(.+){8,15}$/, '必须填写8到15位登录账号']
      ,nickname: function(value){
        if(value.length <= 1){
          return '必须填写人员真实姓名';
        }
      }
      ,gonghao_code: function(value){
        if(value.length <= 1){
          return '必须填写人员工号';
        }
      }
      ,user_mobile: [/^[1][3-9][0-9]{9}$/, '请输入正确的手机号码']
      {if !$info}
      ,pass: [/(.+){6,18}$/, '密码必须6到18位']
      {else}
      ,pass: function(value){
        if(value.length != ''){
          var _reg = /(.+){6,18}$/;
         if(!_reg.test(tel)) return '密码必须6到18位';
        }
      }
      {/if}
    });

    /* 监听提交 */
    form.on('submit(adminInfoForm)', function(data){
      layer.confirm('确定要保存人员信息吗？', {
          title:'保存',shade:[0.4,'#000000'],btn: ['确定','取消'],
          btn1:function(){
              layer.closeAll();
              _Index.ajax("{:url('index/clinic.admin/info')}",data.field,function(d){
                if(d.err == 0)
                {
                  $('#resetBtn').trigger('click');
                  layer.msg(d.msg, {time: 1000},function(){ 
                    window.location.href = "{:url('index/clinic.admin/index')}";
                  });
                }else{
                  layer.msg(d.msg, {time: 2000,anim: 4});
                }
              },'请稍候...');
          }
      });
      return false;
    });
  });
//头像选择后回调
function selectAttachmentFun(_list)
{
  $(".layui-form :input[name='img']").val(_list);
  $('.avatar-img').empty().append('<img src="'+_list+'" id="adminAvatar">');
  layer.close(_dialogLayer);
}
//上传医师资格证图片
function selectYiShiZhengBackFun(_list)
{
  $(".layui-form :input[name='yishi_cert_img']").val(_list);
  layer.close(_dialogLayer);
}
//上传抗菌药物合格格证图片
function selectKangJunBackFun(_list)
{
  $(".layui-form :input[name='kangjun_cert_img']").val(_list);
  layer.close(_dialogLayer);
}
//查看图片 yishi / kangjun
function viewImg(_tag)
{
  _tag = _tag || '';
  if(_tag == 'yishi')
  {
      var _imgUrl = $.trim($(".layui-form :input[name='yishi_cert_img']").val());
  }else{
      var _imgUrl = $.trim($(".layui-form :input[name='kangjun_cert_img']").val());
  }
  if(_imgUrl == '' || _imgUrl.length <= 0)
  {
      layer.msg('请先上传图片', {time: 2000,anim: 4});
      return false;
  }
  layer.open({
    type: 1,
    title:'查看文件',
    area: ['600px', '700px'],
    shade:[0.4,'#000000'],
    anim: 5,
    shadeClose: true,
    content: '<div style="width: 100%;height:100%;text-align: center;"><img src="'+_imgUrl+'" onerror="__imgErr();" style="width: 100%;height:auto;"/></div>'
  });
}
</script>
{/block}